package com.itheima.Regexdemo;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author zhangbaiyan
 * @date 2024-08-19 20:12
 * @description:爬虫
 * @version:
 */
public class test3 {

    public static void main(String[] args) throws IOException,NullPointerException {
        //创建一个URL对象
        URL url = new URL("http://www.uuzzw.com/down/98.html");
        //连接上这个网址
        //细节:保证网络畅通
        URLConnection conn=url.openConnection();
        //创建一个对象去读取网络中的数据
        BufferedReader br =  new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String line;
        //获取正则表达式的对象 patten
        String regex = "[1-9]\\d{16}[\\dxX]";
        Pattern patten = Pattern.compile(regex);
        //在读取的时候每次读一整行
        while ((line=br.readLine())!=null){
//            System.out.println(line);
            Matcher m = patten.matcher(line);
            while (m.find()){
                System.out.println(m.group());
            }
        }
        br.close();



    }

}
